/* @flow */

import { warn } from 'core/util/index';

export * from './attrs';
export * from './class';
export * from './element';

/**
 * Query an element selector if it's not an element already.
 */
export function query(el: string | Element): Element {
    if (typeof el === 'string') {
        const selected = document.querySelector(el);
        if (!selected) {
            // 开发模式，找不到 el 标签器。直接返回div
            process.env.NODE_ENV !== 'production' && warn('Cannot find element: ' + el);
            return document.createElement('div');
        }
        return selected;
    } else {
        // 传入的 el 不是字符串，则是dom对象，直接返回
        return el;
    }
}
